<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    {% block title %}
    <title>后台首页</title>
    {% endblock %}
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="/static/myadmin/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/static/myadmin/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <script src="/static/myadmin/assets/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/static/myadmin/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="/static/myadmin/assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="/static/myadmin/assets/css/app.css">
    <script src="/static/myadmin/assets/js/jquery.min.js"></script>

</head>

<body data-type="index">
    <script src="/static/myadmin/assets/js/theme.js"></script>
    <div class="am-g tpl-g">
        <!-- 头部 -->
        <header>
            <!-- logo -->
            <div class="am-fl tpl-header-logo">
                <a href="javascript:;"><img src="/static/myhome/public/img/logo.png" alt=""></a>
            </div>
            <!-- 右侧内容 -->
            <div class="tpl-header-fluid">
                <!-- 侧边切换 -->
                <div class="am-fl tpl-header-switch-button am-icon-list">
                    <span>

                </span>
                </div>
                <!-- 搜索 -->
                <div class="am-fl tpl-header-search">
                    <form class="tpl-header-search-form" action="javascript:;">
                        <button class="tpl-header-search-btn am-icon-search"></button>
                        <input class="tpl-header-search-box" type="text" placeholder="搜索内容...">
                    </form>
                </div>
                <!-- 其它功能-->
                <div class="am-fr tpl-header-navbar">
                    <ul>
                        <!-- 欢迎语 -->
                        <li class="am-text-sm tpl-header-navbar-welcome">
                            <a href="javascript:;">欢迎你, <span>{{request.session.user.username}}</span> </a>
                        </li>

                        <!-- 新邮件 -->
                        <li class="am-dropdown tpl-dropdown" data-am-dropdown>
                            <a href="javascript:;" class="am-dropdown-toggle tpl-dropdown-toggle" data-am-dropdown-toggle>
                                <i class="am-icon-envelope"></i>
                                <span class="am-badge am-badge-success am-round item-feed-badge">4</span>
                            </a>
                            <!-- 弹出列表 -->
                            <ul class="am-dropdown-content tpl-dropdown-content">
                                <li class="tpl-dropdown-menu-messages">
                                    <a href="javascript:;" class="tpl-dropdown-menu-messages-item am-cf">
                                        <div class="menu-messages-ico">
                                            <img src="/static/myadmin/assets/img/user04.png" alt="">
                                        </div>
                                        <div class="menu-messages-time">
                                            3小时前
                                        </div>
                                        <div class="menu-messages-content">
                                            <div class="menu-messages-content-title">
                                                <i class="am-icon-circle-o am-text-success"></i>
                                                <span>夕风色</span>
                                            </div>
                                            <div class="am-text-truncate"> Amaze UI 的诞生，依托于 GitHub 及其他技术社区上一些优秀的资源；Amaze UI 的成长，则离不开用户的支持。 </div>
                                            <div class="menu-messages-content-time">2016-09-21 下午 16:40</div>
                                        </div>
                                    </a>
                                </li>

                                <li class="tpl-dropdown-menu-messages">
                                    <a href="javascript:;" class="tpl-dropdown-menu-messages-item am-cf">
                                        <div class="menu-messages-ico">
                                            <img src="/static/myadmin/assets/img/user02.png" alt="">
                                        </div>
                                        <div class="menu-messages-time">
                                            5天前
                                        </div>
                                        <div class="menu-messages-content">
                                            <div class="menu-messages-content-title">
                                                <i class="am-icon-circle-o am-text-warning"></i>
                                                <span>禁言小张</span>
                                            </div>
                                            <div class="am-text-truncate"> 为了能最准确的传达所描述的问题， 建议你在反馈时附上演示，方便我们理解。 </div>
                                            <div class="menu-messages-content-time">2016-09-16 上午 09:23</div>
                                        </div>
                                    </a>
                                </li>
                                <li class="tpl-dropdown-menu-messages">
                                    <a href="javascript:;" class="tpl-dropdown-menu-messages-item am-cf">
                                        <i class="am-icon-circle-o"></i> 进入列表…
                                    </a>
                                </li>
                            </ul>
                        </li>

                        <!-- 新提示 -->
                        <li class="am-dropdown" data-am-dropdown>
                            <a href="javascript:;" class="am-dropdown-toggle" data-am-dropdown-toggle>
                                <i class="am-icon-bell"></i>
                                <span class="am-badge am-badge-warning am-round item-feed-badge">5</span>
                            </a>

                            <!-- 弹出列表 -->
                            <ul class="am-dropdown-content tpl-dropdown-content">
                                <li class="tpl-dropdown-menu-notifications">
                                    <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                        <div class="tpl-dropdown-menu-notifications-title">
                                            <i class="am-icon-line-chart"></i>
                                            <span> 有6笔新的销售订单</span>
                                        </div>
                                        <div class="tpl-dropdown-menu-notifications-time">
                                            12分钟前
                                        </div>
                                    </a>
                                </li>
                                <li class="tpl-dropdown-menu-notifications">
                                    <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                        <div class="tpl-dropdown-menu-notifications-title">
                                            <i class="am-icon-star"></i>
                                            <span> 有3个来自人事部的消息</span>
                                        </div>
                                        <div class="tpl-dropdown-menu-notifications-time">
                                            30分钟前
                                        </div>
                                    </a>
                                </li>
                                <li class="tpl-dropdown-menu-notifications">
                                    <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                        <div class="tpl-dropdown-menu-notifications-title">
                                            <i class="am-icon-folder-o"></i>
                                            <span> 上午开会记录存档</span>
                                        </div>
                                        <div class="tpl-dropdown-menu-notifications-time">
                                            1天前
                                        </div>
                                    </a>
                                </li>


                                <li class="tpl-dropdown-menu-notifications">
                                    <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                        <i class="am-icon-bell"></i> 进入列表…
                                    </a>
                                </li>
                            </ul>
                        </li>

                        <!-- 退出 -->
                        <li class="am-text-sm">
                            <a href="{% url "user_logout" %}">
                                <span class="am-icon-sign-out"></span> 退出
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

        </header>
        <!-- 风格切换 -->
        <div class="tpl-skiner">
            <div class="tpl-skiner-toggle am-icon-cog">
            </div>
            <div class="tpl-skiner-content">
                <div class="tpl-skiner-content-title">
                    选择主题
                </div>
                <div class="tpl-skiner-content-bar">
                    <span class="skiner-color skiner-white" data-color="theme-white"></span>
                    <span class="skiner-color skiner-black" data-color="theme-black"></span>
                </div>
            </div>
        </div>
        <!-- 侧边导航栏 -->
        <div class="left-sidebar">
            <!-- 用户信息 -->
            <div class="tpl-sidebar-user-panel">
                <div class="tpl-user-panel-slide-toggleable">
                    <div class="tpl-user-panel-profile-picture">
                        <img src="/static/myadmin/assets/img/user04.png" alt="">
                    </div>
                    <span class="user-panel-logged-in-text">
              <i class="am-icon-circle-o am-text-success tpl-user-panel-status-icon"></i>
              禁言小张
          </span>
                    <a href="javascript:;" class="tpl-user-panel-action-link"> <span class="am-icon-pencil"></span> 账号设置</a>
                </div>
            </div>

            <!-- 菜单  左边栏开始 -->
           <ul class="sidebar-nav">

                <li class="sidebar-nav-link">
                    <a href="/myadmin" class="active">
                        <i class="am-icon-home sidebar-nav-link-logo"></i> 首页
                    </a>
                <!--判断是否是超级管理员-->
                 {% if request.user.is_superuser %}
                <li class="sidebar-nav-link">
                    <a href="javascript:;" class="sidebar-nav-sub-title" id="huiyuanguanli">
                        <i class="am-icon-users sidebar-nav-link-logo"></i>
                        权限管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="{% url 'authuser_index' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                管理员列表
                            </a>
                        </li>

                        <li class="sidebar-nav-link">
                            <a href="{% url 'authgroup_index' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                权限组
                            </a>
                        </li>
                    </ul>
                </li>
                {% endif %}
               <!--判断是否是超级管理员 或 该用户是否在权限组内-->
                {% if request.user.is_superuser or 'myadmin.show_Users' in perms %}
                <li class="sidebar-nav-link">
                    <a href="javascript:;" class="sidebar-nav-sub-title" id="huiyuanguanli">
                        <i class="am-icon-user sidebar-nav-link-logo"></i>
                        会员管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="{% url 'user_list' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                会员列表
                            </a>
                        </li>

                        <li class="sidebar-nav-link">
                            <a href="{% url 'user_add' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                会员添加
                            </a>
                        </li>
                    </ul>
                </li>
                {% endif %}

                {% if request.user.is_superuser or 'myadmin.show_Cates' in perms %}
                <li class="sidebar-nav-link">
                    <a href="javascript:;" class="sidebar-nav-sub-title" id="shangpinfenlei">
                        <i class="am-icon-table sidebar-nav-link-logo"></i>
                        商品分类管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="{% url 'cates_index' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                商品分类列表
                            </a>
                        </li>

                        <li class="sidebar-nav-link">
                            <a href="{% url 'cates_add' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                商品分类添加
                            </a>
                        </li>
                    </ul>
                </li>
               {% endif %}
               <!--判断是否是超级管理员 或商品列表组中的成员-->
               {% if request.user.is_superuser or 'myadmin.show_Goods' in perms %}
                <li class="sidebar-nav-link">
                    <a href="javascript:;" class="sidebar-nav-sub-title" id="shangpinguanli">
                        <i class="am-icon-shopping-bag sidebar-nav-link-logo"></i>
                        商品管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="{% url 'goods_list' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                商品列表
                            </a>
                        </li>

                        <li class="sidebar-nav-link">
                            <a href="{% url 'goods_add' %}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                商品添加
                            </a>
                        </li>
                    </ul>
                </li>
                {% endif %}
               <!--查看用户是否是超级用户 或则是该组成员-->
                {% if request.user.is_superuser or 'myadmin.show_Order' in perms %}
                <li class="sidebar-nav-link">
                    <a href="javascript:;" class="sidebar-nav-sub-title">
                        <i class="am-icon-table sidebar-nav-link-logo"></i>
                        订单管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="{% url 'order_index'%}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span>
                                订单列表
                            </a>
                        </li>
                    </ul>
                </li>

                {% endif %}

            </ul>
            <!--左边栏关闭/-->
        </div>


        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="container-fluid am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                        <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span> 欢迎访问魅族后台管理</div>
                        <!--<p class="page-header-description">Amaze UI 含近 20 个 CSS 组件、20 余 JS 组件，更有多个包含不同主题的 Web 组件。</p>-->
                    </div>
                    <div class="am-u-lg-3 tpl-index-settings-button">
                        <button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>
                    </div>
                </div>

            </div>
            <div class="row-content am-cf">
                {% block con%}
                <form action="" method="POST" enctype="multipart/form-data" class="am-form tpl-form-line-form">
                <h1 style="color:#fff">首页轮播图设置:像素要求1920*480</h1>
                <div class="am-form-group" >
                            <!--<label for="user-name" class="am-u-sm-3 am-form-label" style="color:#fff">-->
                                  <!--<&#45;&#45;&#45;&#45;&ndash;&gt;选择需要修改的图片-->
                                <!--{% csrf_token%}-->
                            <!--</label>-->
                             <select name="pid" style="background:#333">
                                 <option value="1" style="color:#0c79b">第一张图</option>

                                  <option value="2">第二张图</option>

                                  <option value="3">第三张图</option>
                                 <option value="4">第四张图</option>
                             </select>

                        </div>
                <div class="am-u-sm-9">
                                <div class="am-form-group am-form-file">
                                    <div class="tpl-form-file-img">
                                        <!--<img src="/static/myadmin/assets/img/a5.png" alt="">-->
                                         <img src="" alt="" id="showImg" width="100">
                                    </div>
                                    <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                        <i class="am-icon-cloud-upload">
                                        </i>
                                        上传图片
                                    </button>
                                    <!--<input id="doc-form-file" name="pic" type="file" multiple="">-->
                                    <input type="hidden" id="img" />
		                            <input type="file" id="uploadImg" onchange="selectImg(this);" name="pic" multiple=""/>
                                </div>
                            </div>
                <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button class="am-btn am-btn-primary tpl-btn-bg-color-success ">
                                    提交
                                </button>
                            </div>
                        </div>
                    </form>
                {% endblock %}
            </div>
        </div>
    </div>
    </div>
    <script src="/static/myadmin/assets/js/amazeui.min.js"></script>
    <script src="/static/myadmin/assets/js/amazeui.datatables.min.js"></script>
    <script src="/static/myadmin/assets/js/dataTables.responsive.min.js"></script>
    <script src="/static/myadmin/assets/js/app.js"></script>

    <script>
        var image = '';
	var canvas;
	var base64; //将canvas压缩为base64格式
	function selectImg(file) {
		if (!file.files || !file.files[0]) {
			return;
		}
		var reader = new FileReader(); //读取文件
		reader.onload = function(event) { //文件读取完成的回调函数
			image = document.getElementById('showImg');
			image.src = event.target.result; //读入文件的base64数据(可直接作为src属性来显示图片)
			//alert(event.target.result);
			//图片读取完成的回调函数（必须加上否则数据读入不完整导致出错！）
			image.onload = function() {
				canvas = convertImageToCanvas(image); //图片转canvas
				base64 = canvas.toDataURL('image/jpeg'); //将图片数据转为base64.
				//alert(base64);
				$.post(
					"/server_interface_url/", //服务器接口(返回图片路径)
					{
						data: base64
					},
					function(data) {
						alert(data.target);
						//alert(eval(data));
						//修改上传文件的路径名字(图片完整路径)
						$('#img').val('http://path/' + data.target);
					}, "json");
			}
		}
		//将文件已Data URL的形式读入页面
		reader.readAsDataURL(file.files[0]);
	}
	// 把image 转换为 canvas对象
	function convertImageToCanvas(image) {
		// 创建canvas DOM元素，并设置其宽高和图片一样
		var canvas = document.createElement("canvas");
		canvas.width = image.width;
		canvas.height = image.height;
		// 坐标(0,0) 表示从此处开始绘制，相当于偏移。
		canvas.getContext("2d").drawImage(image, 0, 0);

		return canvas;
	}
    </script>
</body>

</html>